package com.cpx.service;

import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

/**
 * @Auther: PanBin
 * @Date: 2018-8-14 15:04
 * @Description: 基础业务层接口
 * @Version: 1.0
 */
public interface BaseService<T> {

    /**
     * @Author: PanBin
     * @Description: 查询所有
     * @CreateDate: 2018-8-15 18:00
     * @Param
     * @Return
     */
    @RequestMapping(value = "/selectAll",method = RequestMethod.GET)
    List<T> selectAll();

    /**
     * @Author: PanBin
     * @Description: 按条件查询
     * @CreateDate: 2018-8-15 18:00
     * @Param: t 查询条件
     * @Return
     */
    @RequestMapping(value = "/select",method = RequestMethod.POST,consumes = "application/json")
    List<T> select(T t);

    /**
     * @Author: PanBin
     * @Description: 根据条件删除
     * @CreateDate: 2018-8-15 18:03
     * @Param: t 删除条件
     * @Return
     */
    @RequestMapping(value = "/delete",method = RequestMethod.POST,consumes = "application/json")
    int delete(T t);

    /**
     * @Author: PanBin
     * @Description: 根据主键删除
     * @CreateDate: 2018-8-15 18:05
     * @Param: o 删除条件
     * @Return 
     */
    @RequestMapping(value = "/deleteByPrimaryKey",method = RequestMethod.POST,consumes = "application/json")
    int deleteByPrimaryKey(Object o);

    /**
     * @Author: PanBin
     * @Description:
     * @CreateDate: 2018-8-15 18:07
     * @Param
     * @Return
     */
    @RequestMapping(value = "/existsWithPrimaryKey",method = RequestMethod.POST,consumes = "application/json")
    boolean existsWithPrimaryKey(Object o);

    /**
     * @Author: PanBin
     * @Description: 添加
     * @CreateDate: 2018-8-15 18:07
     * @Param
     * @Return
     */
    @RequestMapping(value = "/insert",method = RequestMethod.POST,consumes = "application/json")
    int insert(T t);

    /**
     * @Author: PanBin
     * @Description: 添加，忽略null值
     * @CreateDate: 2018-8-15 18:08
     * @Param
     * @Return
     */
    @RequestMapping(value = "/insertSelective",method = RequestMethod.POST,consumes = "application/json")
    int insertSelective(T t);

    /**
     * @Author: PanBin
     * @Description: 根据主键查询
     * @CreateDate: 2018-8-15 18:10
     * @Param
     * @Return
     */
    @RequestMapping(value = "/selectByPrimaryKey",method = RequestMethod.POST,consumes = "application/json")
    T selectByPrimaryKey(@RequestBody Object o);

    /**
     * @Author: PanBin
     * @Description: 根据条件查询数量
     * @CreateDate: 2018-8-15 18:11
     * @Param
     * @Return
     */
    @RequestMapping(value = "/selectCount",method = RequestMethod.POST,consumes = "application/json")
    int selectCount(T t);

    /**
     * @Author: PanBin
     * @Description: 根据条件查询出一条记录
     * @CreateDate: 2018-8-15 18:12
     * @Param
     * @Return
     */
    @RequestMapping(value = "/selectOne",method = RequestMethod.POST,consumes = "application/json")
    T selectOne(T t);

    /**
     * @Author: PanBin
     * @Description: 根据主键查询
     * @CreateDate: 2018-8-15 18:14
     * @Param
     * @Return
     */
    @RequestMapping(value = "/updateByPrimaryKey",method = RequestMethod.POST,consumes = "application/json")
    int updateByPrimaryKey(T t);

    /**
     * @Author: PanBin
     * @Description: 根据主键更新，忽略null值
     * @CreateDate: 2018-8-15 18:14
     * @Param
     * @Return
     */
    @RequestMapping(value = "/updateByPrimaryKeySelective",method = RequestMethod.POST,consumes = "application/json")
    int updateByPrimaryKeySelective(T t);

    /**
     * @Author: PanBin
     * @Description: 批量新增的方法
     * @CreateDate: 2018-8-31 9:46
     * @Param [list]
     * @Return int
     */
    @RequestMapping(value = "/insertList",method = RequestMethod.POST,consumes = "application/json")
    int insertList(List<T> list);

    /**
     * @Author: PanBin
     * @Description: 插入数据，限制为实体包含`id`属性并且必须为自增列，实体配置的主键策略无效
     * @CreateDate: 2018-8-31 9:49
     * @Param [t]
     * @Return int
     */
    @RequestMapping(value = "/insertUseGeneratedKeys",method = RequestMethod.POST,consumes = "application/json")
    int insertUseGeneratedKeys(T t);
}
